<!-- 公司的所有招聘信息 -->
<template>
    <div>
      <reception-header/>
      <el-card shadow="hover" class="card_style">
        <div>
          <el-avatar shape="square" :size="50" :src="companyAvatar"></el-avatar>
          <span class="companyName_Style">{{companyName}}</span>
        </div>
        <div class="smallinfo_style">
          <span class="count_style">{{companyPeopleCount}}人 | </span>
          <span>{{companyLeader}} | </span>
          <span>互联网/IT/电子/电商 | </span>
          <span>上市公司</span>
        </div>
        <el-collapse v-model="activeNames" @change="handleChange" class="collapse_style">
          <el-collapse-item title="公司简介" name="1">
            <el-divider>         
              <span class="introduction">公司介绍</span>         
            </el-divider>
            <div class="jieshao">
              &emsp;&emsp;{{companyIntroduction}}
            </div>
          </el-collapse-item>
          <el-collapse-item title="在招职位" name="2">
            <el-divider>         
              <span class="introduction">在招职位 {{posCount}}个</span>
            </el-divider>
            <div class="jieshao">            
              <div  @click="toRecruitDetailHandle(item.aid)" class="recruit-div" v-for="(item,index) in companyRecruitList" :key="index">
                <el-row>
                  <el-col :span="12">
                    <span class="pos-style">{{item.position}}<el-tag effect="dark" type="success" size="mini" class="xiao-style">校</el-tag></span>
                  </el-col>
                  <el-col :span="12" class="right-style">
                     <span class="salary_style">{{item.salary}}</span>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-tag effect="plain" type="success" size="mini" class="tagbiaoqian-style">{{item.recruitmentAddress.substr(0,2)}}</el-tag>
                    <el-tag effect="plain" type="success" size="mini" class="tagbiaoqian-style">{{item.experience ? item.experience : '不限经验'}}</el-tag>
                    <el-tag effect="plain" type="success" size="mini" class="tagbiaoqian-style">{{item.education ? item.education : '不限学历'}}</el-tag>
                  </el-col>
                  <el-col :span="12" class="right-style">
                    <img class="img-style" src="https://recruitment-files.oss-cn-chengdu.aliyuncs.com/user/hr1.jpg" alt="">
                    <span class="hr-style">HR / 人事经理</span>
                  </el-col>
                </el-row>
              </div>
            </div>
          </el-collapse-item>
          <el-collapse-item title="公司评价" name="3">
              <el-divider>        
                <span class="introduction">公司评价 {{evaluateCount}} 条</span>           
              </el-divider>
              <div class="evaluate-container">
                <div class="view-style">
                  <div class="one-evaluate-style" v-for="(item,index) in evaluateList" :key="index">
                    <div class="avatar-style">
                      <img class="image-style" src="https://recruitment-files.oss-cn-chengdu.aliyuncs.com/user/hr1.jpg" alt="">
                    </div>
                    <div class="time-content-style">
                      <div class="time-style">
                        {{item.createTime}}
                      </div>
                      <div class="content-style">
                        <span style="white-space: pre-wrap;">{{item.content}}</span>                    
                      </div>
                    </div>
                  </div>              
                </div>
                <div class="publish-style">
                  <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="0px" class="demo-ruleForm">
                      <el-form-item prop="content">
                        <el-input 
                          type="textarea" 
                          v-model="ruleForm.content" 
                          :rows="4"
                          placeholder="请发表评论..."
                        >
                        </el-input>
                      </el-form-item>
                       <el-form-item>
                        <el-button type="primary" @click="submitForm('ruleForm')">匿名评价</el-button>
                        <el-button @click="resetForm('ruleForm')">重置</el-button>
                      </el-form-item>
                  </el-form>
                </div>
              </div>
          </el-collapse-item>
          <el-collapse-item title="公司照片" name="4">
            <el-divider>
              <span class="introduction">公司照片</span>
            </el-divider>
            <div style="text-align:center;">
              <img :src="companyPictureUrl" alt="" class="companyPicture_style">
            </div>
          </el-collapse-item>
        </el-collapse>
      </el-card>
    </div>
</template>

<script>
import { getLoginCompanyInfo,getCompanyEvaluateList,submitEvaluation } from "../../../api/enterpriseManage/index";
import ReceptionHeader from '../../../components/ReceptionHeader.vue';
import { getCompanyRecruitInfoList } from "../../../api/recruitmentInfoManage/index";
export default {
  components: { ReceptionHeader, },
  data () {
    return {
      timer: null, // 定时器
      companyAid: 1,
      posCount: 15,
      activeNames: ['1'],
      companyAccount: this.$route.query.name,
      companyAvatar: '',
      companyName: '',
      companyPeopleCount: '',
      companyLeader: '',
      companyIntroduction: '',
      companyAddress: '',
      companyRecruitList:[],
      companyPictureUrl: '',
      experience: '',
      evaluateList: [],
      evaluateCount: 1,
      ruleForm: {
          content: ''
      },
      rules: {
        content: [
          { required: true, message: '先写点东西吧！', trigger: 'blur' }
        ]
      }
    }
  },
  created(){
    // 获取公司所有信息
    this.getCompanyAllInfoFunc();

    // 获取公司所有招聘信息
    this.getcompanyAllRecruitInfoFunc();

    // 获取公司的所有评价
    this.getCompanyEvaluateListfunc();

  },
  beforeDestroy(){
    clearInterval(this.timer); // 清除定时器
    this.timer = null;
  },
  methods:{
    // 获取公司所有信息
    getCompanyAllInfoFunc(){
      const params = {
        account: this.companyAccount,
      }
      getLoginCompanyInfo(params).then(res=>{
        // console.log(res.data.data);
        this.companyAid = res.data.data.aid;
        this.companyPictureUrl = res.data.data.bgImage ? res.data.data.bgImage : 'https://recruitment-files.oss-cn-chengdu.aliyuncs.com/user1647700836000.jpg';
        this.companyAddress = res.data.data.address ? res.data.data.address.substr(0,2) : '全国';
        this.companyIntroduction = res.data.data.introduction ? res.data.data.introduction : '暂无';
        this.companyLeader = res.data.data.leader ? res.data.data.leader : '李总';
        this.companyPeopleCount = res.data.data.employeeCount ? res.data.data.employeeCount : '1000';
        this.companyName = res.data.data.name;
        this.companyAvatar = res.data.data.avatar ? res.data.data.avatar : 'https://recruitment-files.oss-cn-chengdu.aliyuncs.com/user/youshang1.jpg';
      })
    },

    handleChange(val) {
      // console.log(val);
    },

    // 点击职位去招聘职位信息界面
    toRecruitDetailHandle(aid){
      this.$router.push({
        path: "/reception/recruitInfoDetail",
        query: {
          companyAid: this.companyAid,
          recruitmentInfoAid: aid,
        }
      });
    },

    // 获取公司所有招聘信息
    getcompanyAllRecruitInfoFunc(){
      const params = {
        account: this.companyAccount,
      }
      getCompanyRecruitInfoList(params).then(res=>{
        // console.log(res.data.data);
        this.posCount = res.data.data.length;
        this.companyRecruitList = res.data.data;
      })
    },

    // 提交评价
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          const data = {
            content: this.ruleForm.content,
            account: this.companyAccount,
          }
          submitEvaluation(data).then(res=>{
            this.$message.success(res.data.message);
            this.ruleForm.content = '';
          })
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },

    // 获取公司评价列表
    getCompanyEvaluateListfunc(){
      const params = {
        account: this.companyAccount,
      }
      this.timer =  setInterval(() => {
        getCompanyEvaluateList(params).then(res=>{
          this.evaluateCount = res.data.data.length;
          this.evaluateList = res.data.data;
        })
      }, 1000);
   
    }

  }
}
</script>

<style scoped>
.card_style{
  height: 2100px;
}
.companyName_Style{
  margin-left: 25px;
  position: relative;
  bottom: 10px;
  color:  #7d2f61;
  font-size: 30px;
  letter-spacing: 8px;
  text-shadow: 0px 1px 0px #999, 0px 2px 0px #888, 0px 3px 0px #777, 0px 4px 0px #666, 0px 5px 0px #555, 0px 6px 0px #444, 0px 7px 0px #333, 0px 8px 7px #001135
}
.count_style{
  font-size: 14px;
}
.smallinfo_style{
  color: #777;
  font-size: 14px;
}
.introduction{
  margin-left: 8px;
  margin-right: 8px;
  font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
  color: rgba(20, 143, 73, 0.521);
}
.jieshao{
  width: 600px;
  height: 250px;
  background-color: #929eb628;
  margin-left: auto;
  margin-right: auto;
  border-radius: 5px;
  padding-left: 8px;
  padding-right: 8px;
  padding-top: 15px;
  padding-bottom: 8px;
  overflow-y: scroll;
  overflow-x: hidden;
  color: #555;
  font-size: 16px;
}
.jieshao:hover{
  -webkit-box-shadow: #ccc 0px 10px 10px;
  -moz-box-shadow: #ccc 0px 10px 10px;
  box-shadow: #ccc 0px 10px 10px; 
}
.xiao-style{
  position: relative;
  bottom: 3px;
  margin-left: 5px;
}
.tagbiaoqian-style{
  font-size: 4px;
  font-weight: 600;
}
.img-style{
  border-radius: 50%;
  width: 27px;
  height: 27px;
}
.hr-style{
  font-size: 10px;
  font-weight: bold;
  position: relative;
  bottom: 7px;
  color: #777;
}
.recruit-div{
  cursor: pointer;
  background-color: #a0afd15d;
  border-radius: 8px;
  margin-top: 10px;
  margin-bottom: 10px;
}
.recruit-div:hover{
  -webkit-box-shadow: #ccc 0px 10px 10px;
  -moz-box-shadow: #ccc 0px 10px 10px;
  box-shadow: #ccc 0px 10px 10px; 
}
.el-col{
  margin-top: 10px;
  margin-left: 15px;
  width: 260px;
  /* background-color: #001135; */
}
.right-style{
  text-align: right;
}
.pos-style{
  font-size: 20px;
  font-weight: 700;
}
.salary_style{
  font-size: 16px;
  font-weight: 600;
  color: rgba(20, 143, 73, 0.521);
}
.companyPicture_style{
  width: 300px;
  height: 300px;
}
.evaluate-container{
  width: 700px;
  height: 600px;
  margin-left: auto;
  margin-right: auto;
  border-radius: 7px;
  background-color: #929eb628;
  padding-top: 10px;
  padding-left: 10px;
  padding-right: 10px;
  padding-bottom: 10px;
}
.view-style{
  height: 400px;
  width: 700px;
  overflow-y: scroll;
  overflow-x: hidden;
  border-bottom: solid 1px #b7c1d8;
  margin-bottom: 10px;
}
.view-style::-webkit-scrollbar {
  display: none;
}
.publish-style{
  height: 150px;
  width: 600px;
  
}
.avatar-style{
  display: inline-block;
}
.time-content-style{
  display: inline-block;
}
.image-style{
  border-radius: 50%;
  width: 32px;
  height: 32px;
}
.one-evaluate-style{
  margin-bottom: 20px;
}
.demo-ruleForm{
  width: 700px;
}
.jieshao::-webkit-scrollbar {
    display: none;
}
</style>
